<%@ page
   language="java"
   pageEncoding="ISO-8859-1"%>
<%@ taglib
   uri="/WEB-INF/tld/struts-bean.tld/"
   prefix="bean"%>
<%@ taglib
   uri="/WEB-INF/tld/struts-html.tld/"
   prefix="html"%>
<%@ taglib
   uri="http://displaytag.sf.net"
   prefix="display"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld/" prefix="logic"%>

<div class="centerContent">


<h1><bean:message key="pmt.controlAvance.controlAvance" /></h1>
 
<html:form action="/controlAvanceDispatch" styleId="cvForm"  >

 
   <table>
      <tr>
         <td><bean:message key="pmt.controlAvance.proyecto" /></td>
         <td>         
          	<html:select property="proyectoSel" styleId="cmbProyecto" onchange="peticionFunc(); " styleClass="margin-right">
              		<html:option value=""><bean:message key="pmt.combos.primerValor"/></html:option>
                   <html:optionsCollection property="proyectos" label="nombre" value="id" />
          	</html:select>
         </td>
         <td> 
         <html:submit
            property="method"
            styleId="combopeticion"
            styleClass="botoncontrolavance"
            onclick="return validateControlAvanceForm(document.getElementById('cvForm'));">
            <bean:message key="pmt.boton.indyest" />
         </html:submit>
       </td>
   </tr>
   <tr>
      <td><bean:message key="pmt.controlAvance.peticion" /></td>
      <td>
          <html:select property="peticionSel" styleId="cmbPeticion"   onchange="javascript:consultarOculto('submitConsultar');" styleClass="margin-right">
          		   <html:option value=""><bean:message key="pmt.combos.primerValor"/></html:option>
                   <html:optionsCollection property="peticiones" label="nombre" value="id" />
          </html:select>
   </td>
   <td>
     <html:submit
        property="method"
        styleId="comborecurso"
        styleClass="botoncontrolavance"
        onclick="return validateControlAvanceForm(document.getElementById('cvForm'));">
        <bean:message key="pmt.boton.eva" />
     </html:submit>
   </td>
  </tr>
  <tr>
    <td><bean:message key="pmt.controlAvance.recurso" /></td>
    <td>
			<html:select property="recursoSel"   styleId="cmbRecurso" onchange="javascript:consultarOculto('submitConsultar');">
              		<html:option value=""><bean:message key="pmt.combos.todos"/></html:option>
                   <html:optionsCollection property="recursos" label="nombre" value="id" />
              </html:select>
    </td>
	</tr>
</table>

<logic:notEqual  name="controlAvance" property="peticionSel" value="0" >
   <h3><bean:message key="pmt.controlAvance.actualizacion" /> <bean:write name="controlAvance" property="fechaActual"  /></h3>
   <h3><bean:write name="controlAvance" property="nombreProyectoSel"/>/<bean:write name="controlAvance" property="nombrePeticionSel"/>/<bean:write name="controlAvance" property="nombreRecursoSel"/>  </h3>
</logic:notEqual>

 <html:submit
      styleId="submitConsultar"
      style="display:none"
       property="method">
      <bean:message key="pmt.boton.consultar" />
   </html:submit>


<!-- Begin Validator Javascript Function-->
<html:javascript formName="ControlAvanceForm"/>
<!-- End of Validator Javascript Function-->

</html:form>



<script type="text/javascript">
new YAHOO.Hack.FixIESelectWidth('combopeticion');
new YAHOO.Hack.FixIESelectWidth('comborecurso')
</script>

<logic:equal  name="controlAvance" property="peticionSel" value="0" >
<div align="center">
<h2><bean:message key="pmt.combos.seleccionar.proyectoPeticion" /></h2>
</div>
</logic:equal>

<logic:notEqual  name="controlAvance" property="peticionSel" value="0" >
<div
   id="tableContainerCtrlAvance"
   class="tableContainerCtrlAvance ">
   <display:table
   name="controlAvances"
   export="false"
   class="displayTable scrollTableControlAvance"
   id="currentRecurso"
   style="margin: 0px; width:100%"
   pagesize="1000"
   defaultorder="descending"
   decorator="ar.pmt.vista.decoradores.Wrapper">
   <display:setProperty
      name="basic.show.header"
      value="false" />
   <display:caption>
         <thead class="withSelect">
            <tr style="display: block">
               <th
                  style="width: 613px;" class="bggris"><bean:message key="pmt.controlAvance.planificado" /></th>
               <th
                  style="width: 317px;" class="bggris"><bean:message key="pmt.controlAvance.incurrido" /></th>
            </tr>
            <tr>
               <th><select
                  id="numeralSelect"
                  onchange="filterTable(0, this)"></select></th>
               <th><select
                  id="actividadSelect"
                  onchange="filterTable(1, this)"></select></th>
               <th><select
                  id="idSelect"
                  onchange="filterTable(2, this)"></select></th>
               <th><select
                  id="estimadoSelect"
                  onchange="filterTable(3, this)"></select></th>
               <th style="width: 100px"><bean:message key="pmt.controlAvance.esfuerzo" /></th>
               <th style="width: 100px"><bean:message key="pmt.controlAvance.costo" /></th>
               <th style="width: 100px"><bean:message key="pmt.controlAvance.avance" /></th>
               <th><bean:message key="pmt.controlAvance.ganado" /></th>
            </tr>
         </thead>
   </display:caption>
   <display:column
      property="numeral"
      title=""
      style="width: 38px"
      class="center" />

   <display:column
      property="actividad"
      style="width: 299px"
      title="" />

   <display:column
      property="id"
      class="center"
      title=""
      style="width: 48px"
      media="html" />

   <display:column
      property="costoEstimado"
      class="center"
      title=""
      decorator="ar.pmt.vista.decoradores.DecimalWrapper"
      style="width: 120px"
      media="html" />

   <display:column
      property="esfuerzoEstimativo"
      class="center"
      title=""
      decorator="ar.pmt.vista.decoradores.DecimalWrapper"
      style="width: 102px"
      class="right" />

   <display:column
      property="costoReal"
      class="center"
      title=""
      decorator="ar.pmt.vista.decoradores.DecimalWrapper"
      style="width: 99px"
      class="right" />

   <display:column
      property="avance"
      class="center"
      title=""
      decorator="ar.pmt.vista.decoradores.DecimalWrapper"
      style="width: 100px"
      class="right" />

   <display:column
      property="ganado"
      class="center"
      title=""
      decorator="ar.pmt.vista.decoradores.DecimalWrapper"
      style="width: 96px"
      class="right" />

</display:table>

</div>
<script>
if(document.getElementById("cmbPeticion").value != "" ){
	var filterManager = new FilterManager('currentRecurso');
	initFilterSelect('numeralSelect', "<bean:message key="pmt.controlAvance.numeral" />", 0);
	initFilterSelect('actividadSelect', "<bean:message key="pmt.controlAvance.actividad" />", 1);
	initFilterSelect('idSelect', "<bean:message key="pmt.controlAvance.id"/>", 2);
	initFilterSelect('estimadoSelect', "<bean:message key="pmt.controlAvance.costoestimado" />", 3);
}
/** El nodo tfoot tiene q' estar despues de tbody **/
table = document.getElementById("currentRecurso")
tfoot= Builder.node('tfoot',{align:'right', class:'controlAvanceTotales'});
tr = Builder.node('tr');

// totales
td = Builder.node('th',{class:'right', style:'width:399px'},['<bean:message key="pmt.controlAvance.totales" />'])
tr.appendChild(td);

// costo estimado
td = Builder.node('td',{class:'bgLightBlue center', style:'width: 117px;'},['<bean:write name="totalesAvance" property="costoEstimado" format="#,##0.00"   />'])
tr.appendChild(td);

// esfuerzo
td = Builder.node('td',{class:'bgLightBlue center', style:'width: 100px;'},['<bean:write name="totalesAvance" property="esfuerzoEstimativo" format="#,##0.00"  />'])
tr.appendChild(td);

// costo real
td = Builder.node('td',{class:'bgLightBlue center', style:'width: 97px;'},['<bean:write name="totalesAvance" property="costoReal" format="#,##0.00"  />'])
tr.appendChild(td);

// avance
td = Builder.node('td',{class:'bgLightBlue center', style:'width: 98px;'},['<bean:write name="totalesAvance" property="avance" format="#,##0.00"  />'])
tr.appendChild(td);

// ganado
td = Builder.node('td',{class:'bgLightBlue center', style:'width: 112px;'},['<bean:write name="totalesAvance" property="ganado" format="#,##0.00"  />'])
tr.appendChild(td);

tfoot.appendChild(tr);
table.appendChild(tfoot);
</script>
</logic:notEqual>
<script>
window.onload = deshabilitarCombosPeticionRecurso();
</script>
</div>
